package com.uestc.utils;

public class ByteToBinaryString {
    public static String byteToBinaryString(byte b) {
        StringBuilder binaryString = new StringBuilder();
        for (int i = 7; i >= 0; i--) {
            int bit = (b >> i) & 1;
            binaryString.append(bit);
        }
        return binaryString.toString();
    }

    public static void main(String[] args) {
        byte b = (byte) 13; // 例如，13的二进制是00001101
        String binaryString = byteToBinaryString(b);
        System.out.println("The binary representation of " + b + " is: " + binaryString);
    }
}